<?php
include_once('admin-load.php');
    $query = "SELECT * FROM consignee";
    $consignee = $dbna->get_results($query);
    //print_r($users)
   if (isset($_GET['action']) && $_GET['action'] == 'delete') {
       $consignee_id = $_GET['consignee_id'];
       if (isset($_GET['confirm']) && $_GET['confirm']==1) {
           delete_consignee($consignee_id);
       }
       $msg = 'Do you want to delete consignee? <a href="consignee.php?action=delete&consignee_id='.$consignee_id.'&confirm=1">YES</a> <a href="consignee.php">NO</a>';
   }
?>
<?php
	include_once 'header.php';
?>
            <div id="main_content">
			    <div id="content">
                    
		</div>
        <div class="container">
            <h5>Consignee List</h5>

        </div>
				<div id="main">
                    <h2>Consignee List</h2>
                    <?php
                        if (isset($msg)) {
                            echo '<div class="warning">'. $msg . '</div>';
                        }
                    ?>
                    <table>
                        <thead>
                            <tr>
                                <th>Receive Name</th>
                                <th>Phone</th>
                                <th>Fax</th>
                                <th>Country</th>
                                <th>Zip</th>
                                <th>Edit/Delete</th>
                            </tr>
                        </thead>
                        <tbody>
                           <?php
                                if (!empty ($consignee)) {
                                    foreach($consignee as $u) {
                                         $edit = '<a href="consignee-edit.php?consignee_id='.$u->id.'"> Edit</a>';
                                         $delete = '<a href="consignee.php?action=delete&consignee_id='.$u->id.'">Delete</a>';
                                        printf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
                                                $u->receive_name, $u->phone, $u->fax, $u->country, $u->zip, $edit. ' '.$delete
                                                );
                                    }
                                }
                            ?>
                        </tbody>
                    </table>
				
            </div>
           <?php 
	include_once 'footer.php';
?>